//********************************************************************
//	created:	26:3:2011   16:28
//	filename: 	zlibhelper.cpp
//	author:		tiamo
//	purpose:	zlib helper
//********************************************************************

#include "stdafx.h"
#include "zlibhelper.h"

namespace zlib
{
	//
	// compress buffer
	//
	uint32_t compressBuffer(void const* inputBuffer, uint32_t inputLength, void* outputBuffer, uint32_t outputLength)
	{
		uLong destLength													= outputLength;
		compress(static_cast<Bytef*>(outputBuffer), &destLength, static_cast<Bytef const*>(inputBuffer), static_cast<uLongf>(inputLength));
		return destLength;
	}

	//
	// uncompress buffer
	//
	uint32_t uncompressBuffer(void const* inputBuffer, uint32_t inputLength, void* outputBuffer, uint32_t outputLength)
	{
		uLong destLength													= outputLength;
		uncompress(static_cast<Bytef*>(outputBuffer), &destLength, static_cast<Bytef const*>(inputBuffer), static_cast<uLongf>(inputLength));
		return destLength;
	}
}
